import React from 'react'
import Store from '../../Store/store'
import {increatmentAction,decreatmentAction} from '../../Store/Actions/countaction'
export default function Count() {
    const {count} = Store.getState()
    const inCreamhandel = ()=>{
        Store.dispatch(increatmentAction(1))
    }
    const deCreamhandel = ()=>{
        Store.dispatch(decreatmentAction(1))
    }
    const inOddhandel = ()=>{
        if(count % 2 !== 0 ){
            Store.dispatch(increatmentAction(1))
        }
    }
    const inTimeouthandle = ()=>{
        setTimeout(()=>{
            Store.dispatch(increatmentAction(1))
        },2000)
    }
  return (
    <div>
        <h1>我是Count组件 我的个数是{count}</h1>
         <button onClick={inCreamhandel}>累加 </button>
         <button onClick={deCreamhandel}>累减 </button>
         <button onClick={inOddhandel}>基数+1 </button>
         <button onClick={inTimeouthandle}>过两秒+1</button>
    </div>
   
  )
}
